const { defineConfig } = require('@vue/cli-service')

const path = require('path')
function resolve(dir) {
  return path.join(__dirname, dir)
}

module.exports = defineConfig({
  transpileDependencies: true,
  publicPath: process.env.NODE_ENV === 'production' ? '/<%= data.name %>/' : '/',
  outputDir: '<%= data.name %>',
  assetsDir: 'staticAssets',
  indexPath: 'index.html',
  productionSourceMap: true,
  lintOnSave: false,
  runtimeCompiler: true,
  devServer: {
    client: {
      overlay: false
    },
    //
    proxy: {
      '/xxx': {
        target: 'http://xxx', // write your proxy target
        changeOrigin: true,
      },
    }
  },<% if ( data.cssProcess ) { %>
    css: {
      loaderOptions: {
        scss: {
          prependData: '@import "src/assets/scss/variable.scss";'
        }
      }
    },
  <% } %>
  chainWebpack: config => {
    config.resolve.alias.set('@', resolve('src')).set('@S', resolve('static'))
    // 移除 prefetch 插件
    config.plugins.delete('prefetch')
    config.plugin('html').tap(args => {
      args[0].title = '<%= data.name %>'
      return args
    })
  },
})
